// 清除浮动
@mixin clearfix {
  &::after {
    content: '';
    display: table;
    clear: both;
  }
}

// 文本省略
@mixin ellipsis {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

// 多行文本省略
@mixin ellipsis-lines($lines: 2) {
  display: -webkit-box;
  -webkit-line-clamp: $lines;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

// 垂直水平居中
@mixin center {
  display: flex;
  justify-content: center;
  align-items: center;
}

// 绝对定位居中
@mixin absolute-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

// 固定宽高比
@mixin aspect-ratio($width, $height) {
  position: relative;
  
  &::before {
    content: '';
    display: block;
    width: 100%;
    padding-top: ($height / $width) * 100%;
  }
  
  > * {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
  }
}

// 按钮重置
@mixin button-reset {
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  cursor: pointer;
  outline: none;
  
  &:focus {
    outline: none;
  }
}

// 输入框重置
@mixin input-reset {
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  outline: none;
  box-shadow: none;
  
  &:focus {
    outline: none;
    box-shadow: none;
  }
}

// 滚动条样式
@mixin scrollbar($width: 6px, $track-color: var(--kexilo-fill-color-lighter), $thumb-color: var(--kexilo-border-color-darker)) {
  &::-webkit-scrollbar {
    width: $width;
    height: $width;
  }
  
  &::-webkit-scrollbar-track {
    background: $track-color;
    border-radius: $width / 2;
  }
  
  &::-webkit-scrollbar-thumb {
    background: $thumb-color;
    border-radius: $width / 2;
    
    &:hover {
      background: var(--kexilo-border-color-dark);
    }
  }
}

// 响应式断点
@mixin mobile {
  @media (max-width: 767px) {
    @content;
  }
}

@mixin tablet {
  @media (min-width: 768px) and (max-width: 1023px) {
    @content;
  }
}

@mixin desktop {
  @media (min-width: 1024px) {
    @content;
  }
}

@mixin large-desktop {
  @media (min-width: 1200px) {
    @content;
  }
}

// 主题色渐变
@mixin primary-gradient {
  background: linear-gradient(135deg, var(--kexilo-primary) 0%, var(--kexilo-primary-light-3) 100%);
}

// 卡片样式
@mixin card {
  background: var(--kexilo-bg-color);
  border-radius: var(--kexilo-border-radius-base);
  box-shadow: var(--kexilo-box-shadow-lighter);
  border: 1px solid var(--kexilo-border-color-lighter);
}

// 动画过渡
@mixin transition($property: all, $duration: var(--kexilo-transition-duration), $timing: ease) {
  transition: $property $duration $timing;
}

// 禁用状态
@mixin disabled {
  opacity: var(--kexilo-disabled-opacity);
  cursor: not-allowed;
  user-select: none;
  pointer-events: none;
}

// 加载状态
@mixin loading {
  position: relative;
  pointer-events: none;
  
  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    z-index: 1;
  }
  
  &::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--kexilo-primary);
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: loading-spin 1s linear infinite;
    z-index: 2;
  }
}

@keyframes loading-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

// 隐藏文本
@mixin sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

// 三角形
@mixin triangle($direction: up, $size: 6px, $color: var(--kexilo-text-color-secondary)) {
  width: 0;
  height: 0;
  border-style: solid;
  
  @if $direction == up {
    border-width: 0 $size $size $size;
    border-color: transparent transparent $color transparent;
  } @else if $direction == down {
    border-width: $size $size 0 $size;
    border-color: $color transparent transparent transparent;
  } @else if $direction == left {
    border-width: $size $size $size 0;
    border-color: transparent $color transparent transparent;
  } @else if $direction == right {
    border-width: $size 0 $size $size;
    border-color: transparent transparent transparent $color;
  }
}
